import { ref, watch } from 'vue'
import { useUserStore } from '@/store'

export function useEmptyImgPath() {
    return new URL('/src/assets/imgs/empty.png', import.meta.url).href
}

export function useLoginPopup() {
    const status = ref(false)
    const open = () => {
        status.value = true
    }
    const close = () => {
        status.value = false
    }

    return {
        status,
        open,
        close
    }
}

export function useWaitUserLoadFn(callback) {
    const userStore = useUserStore()
    if (!userStore.loading) {
        callback()
        return
    }
    watch(
        () => userStore.loading,
        (value) => {
            if (!value) {
                callback()
            }
        }
    )
}